package net.wicp.tams.plugin.task.kubernetes;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

import net.wicp.tams.common.Result;
import net.wicp.tams.common.apiext.StringUtil;
import net.wicp.tams.common.others.kubernetes.KubeClient;
import net.wicp.tams.plugin.TaskAssit;

@Mojo(name = "delrc", requiresProject = false, threadSafe = false)
public class DelRc extends AbstractMojo {

	@Parameter(property = "rc", required = true)
	private String rc;
	/**
	 * apiserver的url
	 */
	@Parameter(property = "url", required = false)
	private String url;

	@Parameter(defaultValue = "default", property = "namespace", required = false)
	private String namespace;

	@Parameter(property = "callback", required = false)
	private String callback;
	// 回调的会话id
	@Parameter(property = "msgid", required = false)
	private String msgid;

	@Override
	public void execute() throws MojoExecutionException, MojoFailureException {
		TaskAssit.initMasterUrl(url);
		KubeClient.delRc(namespace, rc);
		TaskAssit.sendMsg(getLog(), callback, msgid);
		getLog().info("------------------------删除rc成功：" + rc + "---end---------");
	}

}
